"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemSettingDao = void 0;
const DbConfig_1 = require("../../src/config/DbConfig");
const DaoBase_1 = require("../../src/engine/dao/DaoBase");
const Logger_1 = require("../../src/engine/utils/Logger");
const MysqlManager_1 = require("../../src/engine/utils/MysqlManager");
class SystemSettingDao extends DaoBase_1.DaoBase {
    static update_system_setting(key, value) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "replace into t_system_setting (setting_key,setting_value) values(?,?)";
            let sqlParams = [key, value];
            let results = yield client.queryPromise(sql, sqlParams);
            Logger_1.Logger.log("update_system_setting==", sql, sqlParams, results);
            if (results && results["affectedRows"] > 0) {
                return true;
            }
            else {
                return false;
            }
        });
    }
    static get_system_setting(key) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "select * from t_system_setting where setting_key=?";
            let sqlParams = [key];
            let results = yield client.queryPromise(sql, sqlParams);
            let setting_value = "";
            if (results && results.length > 0) {
                setting_value = results[0]["setting_value"];
            }
            return setting_value;
        });
    }
    static get_notice() {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "select * from t_system_setting where setting_key='notice'";
            let results = yield client.queryPromise(sql);
            Logger_1.Logger.log("get_notice==", results);
            let notice = "";
            if (results && results.length > 0) {
                notice = results[0]["setting_value"];
            }
            return notice;
        });
    }
    static get_choushui() {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "select * from t_system_setting where setting_key='choushui'";
            let results = yield client.queryPromise(sql);
            Logger_1.Logger.log("get_choushui==", results);
            let notice = "";
            if (results && results.length > 0) {
                notice = results[0]["setting_value"];
            }
            return notice;
        });
    }
}
exports.SystemSettingDao = SystemSettingDao;
SystemSettingDao.DB_NAME = DbConfig_1.DbConfig.Db_Name.db_admin;
